<?php
namespace Home\Controller\SuperUser;
use Think\Controller;
class IndexController extends Controller {

    function _initialize(){
        // \Think\Hook::add('login','Home\\Behaviors\\testBehavior');
    }

    public function index(){
    	// layout(true);
    	// $this->display();
        // $hello = "hello";
        // \Think\Hook::listen('login',$hello);//
        $this->display("SuperUser:index");
    }

/**
 * 9.1
 * [countVip 会员统计]
 * @return [type] [description]
 */ 
    public function updatebadge(){
        $start=I('post.start');
        $end = I('post.end');
        if($start&&$end){
            //新增会员数
            $User = M('User');
            $map['datetime'] = array('between',array($start,$end));    
            $result['newvip'] = $User->where($map)->count();  
            //新增交易额
            $Order = M("Order"); 
            $result['neworder']= $Order->where($map)->count();  
            $result['newsale'] = $Order->where($map)->sum('sum');  
            if($result['newsale']==null)$result['newsale']=0;
            //新增商家
            $Shop = M('Shop');
            $map['time'] = array('between',array($start,$end));    
            $result['newshop'] = $Shop->where($map)->count();  
            //新增
        }else{
            $result['newvip'] = 0;
            $result['neworder'] = 0;
            $result['newshop'] = 0;
            $result['newsale'] = 0;
        }


        echo json_encode($result);
        //5.当月新增用户
        //6.七天用户增长数
        //7.最近一个月用户数目变化
        //8.最近一年用户变化
    }
}